package nanhua.spring_aop.OrderService.Impl;

import lombok.extern.slf4j.Slf4j;
import nanhua.spring_aop.OrderService.OrderService;
import nanhua.spring_aop.aop.MyAspect;
import nanhua.spring_aop.aop.OrderAnnotiation;
import nanhua.spring_aop.pojo.number;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private MyAspect myAspect;

    @OrderAnnotiation
    @Override
    public int add(String pname, int number) {
        if (!myAspect.checkPermission()) {
            return 0; // 权限不足，终止执行
        }
        System.out.println("你好，我是添加操作");
        return 1;
    }

    @OrderAnnotiation
    @Override
    public int delete(String pname) {
        if (!myAspect.checkPermission()) {
            return 0; // 权限不足，终止执行
        }
        System.out.println("你好，我是删除操作");
        return 1;
    }

    @OrderAnnotiation
    @Override
    public number find(String pname) {
        System.out.println("你好，我是查询操作");
        return null;
    }
}
